package demo7;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

//import javax.annotation.PostConstruct;
//import javax.annotation.PreDestroy;

@Component
public class Person {
private String name;

public Person() {
    System.out.println("1:Person的构造方法调用了");
}


    public String getName() {
        return name;
    }
    @Value("张三")
    public void setName(String name) {
        System.out.println("2:Person的setName方法调用了,初始化name属性");
        this.name = name;
    }

    @Override
    public String toString() {
        return "Person{" +
                "name='" + name + '\'' +
                '}';
    }
   // @PostConstruct
    public void postConstruct()
    {
    	System.out.println("3:Person的postConstruct方法调用了");

    }
   // @PostConstruct
    public void play(){
        System.out.println("4:正常的方法调用了");
    }
    //@PreDestroy
    public void preDestroy(){
        System.out.println("5:Person的preDestroy方法调用了");
    }





}
